import java.util.ArrayList;
import java.util.Arrays;

class Solution {


    public static String[] sortPeople(String[] names, int[] heights) {
        int n=heights.length;
        Integer[] index=new Integer[n];
        for(int i=0;i<n;i++) index[i]=i;
        Arrays.sort(index,(a,b)-> Integer.compare(b,a));
        Arrays.sort(index, (a, b) -> heights[b] - heights[a]);
         Arrays.sort(index,(a,b)->heights[b]-heights[a]);
        String[] ret=new  String[n];
        for(int i=0;i<n;i++) ret[i]=names[index[i]];
        return ret;

    }

    public static void main(String[] args) {
        String[] strings = sortPeople(new String[]{"rtgd", "sejfoi"}, new int[]{15, 56});
        for(String s:strings) System.out.println(s);
    }
}


class Solution1 {
    public int maxEnvelopes(int[][] envelopes) {
        int n=envelopes.length;
        ArrayList<Integer> arr=new ArrayList<>();
        Arrays.sort(envelopes,(a,b)->{
            if(a[0]!=b[0]) return a[0]-b[0];
            else return b[1]-a[1];
        });

        arr.add(envelopes[0][1]);

        for(int i=1;i<n;i++){
            int num=envelopes[i][1];
            if(num>arr.get(arr.size()-1)) arr.add(num);
            else{
                int left=0;
                int right=arr.size()-1;
                int mid=(right-left)/2+left;
                while(left<right){
                    mid=(right-left)/2+left;
                    if(arr.get(mid)<num) left=mid+1;
                    else right=mid;
                }
                arr.set(right,num);
            }

        }

        return arr.size();

    }
}